﻿using System;
using System.Globalization;

namespace Silverlight.SqlStatementEvaluator
{
    /// <summary>
    /// Provides character from string
    /// </summary>
    internal class CharacterProvider
    {
        #region Data Fields
        /// <summary>
        /// Text length
        /// </summary>
        private int _lengh;

        /// <summary>
        /// Current position
        /// </summary>
        private int _position;

        /// <summary>
        /// Holds text
        /// </summary>
        private string _text;
        #endregion

        #region Constructors
        /// <summary>
        /// Default constructor
        /// </summary>
        public CharacterProvider(string text)
        {
            this._text = text.ToUpper(CultureInfo.InvariantCulture);
            this._lengh = this._text.Length;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets character
        /// </summary>
        public char Character
        {
            get
            {
                if (this._position >= this._lengh)
                {
                    return '\0';
                }

                return this._text[this._position];
            }
        }
        #endregion

        #region Methods
        /// <summary>
        /// Returns next character
        /// </summary>
        public void MoveNext()
        {
            this._position++;
        }
        #endregion
    }
}
